package io.mft.api.domain;

import java.io.Serializable;
import java.util.List;

import io.mft.commons.function.response.kv.KVMap;
import io.mft.commons.util.Unique;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class InputParameterJsonFormat implements Unique,ActualKeyInitor,Serializable{
	 
	        /**
	 * @说明：TODO
	 * @字段名称 serialVersionUID
	        */  
	    
	private static final long serialVersionUID = 1999589139996272734L;
	public static enum JsonFormat {
		none,simple, editDatagrid
	}
/**
	@Getter
	@Setter
	public static class JsonFormatType implements Unique, ActualKeyInitor{
		private JsonFormat mode=JsonFormat.simple;
		private List<InputParameter> editDatagridKeys;
		//private List<KVMap> simpleParameters;
		@Override
		public KVMap initActualKey(boolean toUnderlineCase) {
			KVMap map=new KVMap();
			if (editDatagridKeys!=null) {
				for (InputParameter inputParameter : editDatagridKeys) {
					KVMap kvMap=inputParameter.initActualKey(toUnderlineCase);
					map.putAll(kvMap);
				}
			}
			return map;
		}
		@Override
		public String uniqueId() {
			String uid=mode.name();
			if (editDatagridKeys!=null) {
				for (InputParameter inputParameter : editDatagridKeys) {
					uid=uid+"-"+inputParameter.uniqueId();
				}
			}
			return uid;
		}
	}
**/
	//private JsonFormatType type;
	private List<InputParameter> keys;
	@Override
	public KVMap initActualKey(boolean toUnderlineCase) {
		KVMap map=new KVMap();
		//if (type!=null) {
		//	KVMap m=type.initActualKey(toUnderlineCase);
		//	map.putAll(m);
		//}
		
		if (keys!=null) {
			for (InputParameter inputParameter : keys) {
				KVMap kvMap=inputParameter.initActualKey(toUnderlineCase);
				map.putAll(kvMap);
			}
		}
		return map;
	}
	@Override
	public String uniqueId() {
		String uid="";
		//if (type!=null) {
		//	uid=type.uniqueId();
		//}
		if (keys!=null) {
			for (InputParameter inputParameter : keys) {
				uid=uid+"-"+inputParameter.uniqueId();
			}
		}
		return uid;
	}

}
